Component({
    data: {
        active: null,
        isSafeArea: false,
        tabbarlist: [{
                name: '首页',
                iconAC: 'https://www.ldxs.info/static/tab/home_active.png',
                icon: 'https://www.ldxs.info/static/tab/home.png',
                url: '/pages/home/home',
                type: 'menu',
                id: 1
            },
            {
                name: '商城',
                iconAC: 'https://www.ldxs.info/static/tab/shopping_active.png',
                icon: 'https://www.ldxs.info/static/tab/shopping.png',
                url: '',
                type: 'btn',
                id: 2
            },
            {
                name: '我的',
                iconAC: 'https://www.ldxs.info/static/tab/mine_active.png',
                icon: 'https://www.ldxs.info/static/tab/mine.png',
                url: '/pages/mine/mine',
                type: 'menu',
                id: 3
            },
        ]
    },
    methods: {
        switchTabFN: function(e) {
            let item = e.currentTarget.dataset.item
            let index = e.currentTarget.dataset.index
            if (index == this.data.active) return
            console.log(item, '====点击')
            if (item.type === 'menu') {
                wx.switchTab({
                    url: item.url
                })
            } else {
                wx.navigateToMiniProgram({
                    appId: 'wxc72b0171ffddb8f7',
                    success(res) {
                        // 打开成功
                    }
                })
            }
        },
        isIPhoneX: function() {
            let screenHeight, bottom
            wx.getSystemInfo().then((res) => {
                console.log(res)
                screenHeight = res.screenHeight
                bottom = res.safeArea.bottom
                this.setData({
                    isSafeArea: (screenHeight !== bottom)
                })
            });
        }
    },

    created() {
        this.isIPhoneX()
    },
})